//
//  NewsCell.m
//  sensen_ios
//
//  Created by mc on 16/3/23.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "NewsCell.h"

@implementation NewsCell

+(instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString * cellIdentifier = @"NewsCell";
    NewsCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell ==nil) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self setupSubViews];
        
    }
    return self;
}


- (void)setupSubViews{
    self.ivContent = [[UIImageView alloc] init];
    //[self.ivContent setBackgroundColor:[UIColor redColor]];
    [self addSubview:self.ivContent];
    [self.ivContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.centerY.equalTo(self.mas_centerY).offset(0);
        make.size.mas_equalTo(CGSizeMake(80, 60));
        
    }];
    //self.ivContent.image = [UIImage imageNamed:@"新闻"];
    
    self.lblTitle = [[UILabel alloc] init];
    [self addSubview:self.lblTitle];
    [self.lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ivContent.mas_right).offset(10);
        make.right.equalTo(self).offset(-5);
        make.top.equalTo(self.ivContent.mas_top).offset(5);
        make.height.equalTo(@20);
    }];
    self.lblTitle.font = [UIFont systemFontOfSize:15];
    self.lblTitle.numberOfLines = 0;
    self.lblTitle.textColor = [BoyeTool colorFromHexRGB:@"#666666"];
    
    self.lblDetail = [[UILabel alloc] init];
    [self addSubview:self.lblDetail];
    [self.lblDetail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ivContent.mas_right).offset(10);
        make.right.equalTo(self).offset(-5);
        make.bottom.equalTo(self.ivContent.mas_bottom).offset(-5);
        make.height.equalTo(@20);
    }];
    self.lblDetail.font = [UIFont systemFontOfSize:12];
    self.lblDetail.numberOfLines = 1;
    self.lblDetail.textColor = [UIColor lightGrayColor];

//    self.lblDetail.backgroundColor = [UIColor redColor];
//    self.lblTitle.backgroundColor = [UIColor greenColor];
    
//    self.lblTitle.text = @"宠物与水族展首次联合举办 明年三月更多萌宠物前来其中包括狮子老虎";
//    self.lblDetail.text = @"羊城晚报讯 记者李文杰报道：明年三月更多萌宠物前来其中包括狮子老虎";
}

- (void)setModel:(PostReplyModel *)model{
    _model = model;
    [self.ivContent setImageURLStr:model.main_img placeholder:DEFAULT_IMAGE];
    self.lblTitle.text = model.post_title;
    self.lblDetail.text = model.post_excerpt;
}



@end
